import Vue from 'vue'
import App from './App'
import store from './store'

const msg = (title, icon='none')=>{
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration:1500,
		mask:true,
		icon
	});
}

const ajax = (url,data,callfun,okfun)=>{
	let baseurl='https://dyt.dghksl.com/api/app/';
	//let baseurl='http://192.168.120.116:4912/api/app/';
	uni.request({
		url: baseurl+url,
		dataType: 'json',
		method:'POST',
		data: data
	}).then(res => {
		callfun(res);
	}).catch(err => {
		uni.showModal({
			content: err.errMsg,
			showCancel: false
		});	
		if (okfun) okfun(err);
	});
}

const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}


Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$store = store;
//Vue.prototype.$url ='http://192.168.120.116:4912';
Vue.prototype.$url ='https://dyt.dghksl.com';
Vue.prototype.$api = {msg,ajax, prePage};

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
